package Common

import (
	m "../model"
	pp "../protobuf"
)

func Quuestion(r m.Questions,cha chan *pp.Questions )  {
	var dat=pp.Questions{
		QuestionsID: r.QuestionsID,
		SyllabusKnowledgePointID:r.SyllabusKnowledgePointID,
		Title:r.Title      ,
		Name:r.Name       ,
		Type:r.Type         ,
		Difficulty:r.Difficulty   ,
		State:r.State      ,
		Anws:[]*pp.Answer{},
	}
	var ans []*pp.Answer

	for _,r:= range r.Answers{
		//fmt.Printf("我是测试%+v\n",r)
		var d=pp.Answer{
			Answerid: r.Answerid,
			Questionsid:r.Questionsid,
			Content:r.Content      ,
		}

		ans= append(ans, &d)

	}
	dat.Anws=ans
	cha<- &dat
	return
}
func Userknowledgepoint(r *pp.Userknowledgepoint) m.Userknowledgepoint  {
	var dat=m.Userknowledgepoint{
		UserknowledgepointID: r.UserknowledgepointID,
		CourseID:r.CourseID,
		SyllabusKnowledgePointID:r.SyllabusKnowledgePointID      ,
		Userid:r.Userid       ,
		AddTime:r.AddTime   ,
		IsRight:r.IsRight   ,
	}
	return  dat
}
